<template>
  <div class="info-error">
    <div class="title-bar">
      <h1>信息异常</h1>
    </div>
    <div class="info-error-box" :class="{'justify-center': !wechatImg}">
      <div class="info-error-img">
        <img src="./assets/err.png" alt="">
      </div>
      <div class="info-error-code">
        编号：{{errorNum}}
      </div>
      <p class="info-error-tip">
        您的微信号信息异常，为保证公平公<br />正您暂时无法继续访问该活动！
      </p>
      <div v-if="wechatImg">
        <div class="qrcode-img">
          <img :src="wechatImg" alt="">
        </div>
        <p class="qrcode-tip">
          长按识别二维码<br />添加微信客服
        </p>
      </div>
    </div>
    <SuccessFooter></SuccessFooter>
  </div>
</template>

<script>
import TitleBar from '../../components/TitleBar'
import SuccessFooter from '../../components/SuccessFooter'
import Cookie from 'js-cookie'
import * as events from '../../store/events'

export default {
  components: {
    TitleBar,
    SuccessFooter
  },
  data() {
    return {
      // 编码
      errorNum: '',
      // 电话
      serviceTel: '',
      // 微信客服
      wechatImg: ''
    }
  },
  mounted() {
    this.check()
  },
  methods: {
    check() {
      this.$showLoading()
      this.$api.oauthLogin(this.$route.params.catid, '', '').then(data => {
        this.$hideLoading()
        if (parseInt(data.data.status) === 20000) {
          this.errorNum = data.data.error_num
          this.serviceTel = data.data.service_tel
          this.wechatImg = data.data.wechatqr
          // 客服数据
          let service = {
            qq: data.data.qq, // 客服qq号码
            wxqr: data.data.wechatqr, // 客服微信二维码
            tel: data.data.service_tel   // 客服电话
          }
          // 客服数据存到store中
          this.$store.commit(events.SET_SERVICE_INFO, service)
        } else {
          this.$router.replace('/?catid=' + this.$route.params.catid)
        }
      }).catch(() => {
        this.$hideLoading()
      })
    }
  }
}
</script>

<style scoped lang="scss">
.info-error {
  min-height: 100vh;
  background-color: #fff;
  .title-bar {
    width: 100%;
    height: 0.88rem;
    line-height: 0.88rem;
    h1 {
      width: 100%;
      text-align: center;
      font-size: 0.36rem;
      color: rgba(51, 51, 51, 1);
      font-weight: 700;
    }
  }
  .info-error-box {
    position: absolute;
    top: 0.88rem;
    bottom: 1.6rem;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }
  .justify-center {
    justify-content: center;
  }
  .info-error-img {
    text-align: center;
    img {
      width: 5.25rem;
      height: auto;
    }
  }
  .info-error-code {
    text-align: center;
    font-size: 0.3rem;
    color: #f77c22;
  }
  .info-error-tip {
    font-size: 0.3rem;
    color: #666;
    line-height: 0.5rem;
    text-align: center;
  }
  .qrcode-img {
    text-align: center;
    margin: 0 auto 0 auto;
    width: 1.9rem;
    height: 1.9rem;
    img {
      width: 100%;
      height: 100%;
    }
  }
  .qrcode-tip {
    text-align: center;
    font-size: 0.28rem;
    color: #999;
    line-height: 0.5rem;
  }
  .contact-box {
    position: fixed;
    width: 100%;
    height: 1.6rem;
    left: 0;
    bottom: 0;
    padding: 0.25rem 0.67rem;
    background-color: #f8f7f5;
    .contact-tip {
      font-size: 0.26rem;
      color: #bfbfbf;
      img {
        margin-left: 0.1rem;
        margin-right: 0.1rem;
        vertical-align: -0.02rem;
        width: 0.26rem;
        height: auto;
      }
    }
    .contact-box-inner {
      display: flex;
      justify-content: center;
      margin-top: 0.3rem;
    }
    .contact-item {
      img {
        height: 0.43rem;
        width: auto;
        vertical-align: middle;
      }
      span {
        vertical-align: middle;
        color: #739efb;
        font-size: 0.34rem;
        margin-left: 0.15rem;
        font-weight: 700;
      }
    }
  }
}
</style>
